﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SocketLib;
using System.Threading;
using SocketLib.Buffers;
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {

            Remote rem = new Remote();
            rem.start();
            rem.SendMsg("开始连接");
            Console.ReadKey();
        }
      
    }

    class Remote
    {
       SocketLib.Client2 svc = new SocketLib.Client2();
       public void start()
        {
            //svc.Connect("172.29.226.77", 3451);
			svc.Connect("192.168.1.2", 3451);
            svc.ReceiveEventHandler += new SocketLib.Client2.ReceiveDelegate(svc_ReceiveEventHandler);
            svc.Callback_EventHandler += new Client2.CallbackDelegate(svc_Callback_EventHandler);
           
        }

	   public void SendMsg(string msg)
	   {
	    svc.SendMsg(msg);

	   }

       void svc_Callback_EventHandler(object sender, Client2.CallbackEventArgs e)
       {
           IPMPack c = new IPMPack();
           c.UnPacked(e.buffer);


           if (c.PackType == 1)
           {

               string str = System.Text.Encoding.Default.GetString(c.Data);
               Console.WriteLine(str);
           }
       }
       void svc_ReceiveEventHandler(object sender, SocketLib.Client2.ReceiveEventArgs e)
       {

           Console.WriteLine(e.msg);
       }

       void s_CallbackEventHandler(object sender, SocketLib.Client2.CallbackEventArgs e)
       {

           IPMPack c = new IPMPack();
           c.UnPacked(e.buffer);
           Console.WriteLine(Encoding.UTF8.GetString(c.Data));

       }


    }
}
